package example.hanoitower;

/**
 * @description: 汉诺塔
 * @author Administrator
 * @date 2022/2/5 20:28
 * @version 1.0
 */
public class HanoiTower {
    public static void moveDish(int level, char from, char inter, char to) {
        if (level == 1) {
            System.out.println("从 " + from + " 移动盘子 1 号到 " + to);
        } else {
            moveDish(level - 1, from, to, inter);
            System.out.println("从 " + from + " 移动盘子 " + level + " 号到 " + to);
            moveDish(level - 1, inter, from, to);
        }
    }
    
    public static void main(String[] args) {
        int nDisks = 3;
        moveDish(nDisks, 'A', 'B', 'C');
    }
}
